﻿/* 2012/11/8 */
using System;
using System.IO;

namespace Cosmos.IO.FileSystemPath.Searcher
{
    /// <summary>
    /// Represents a matcher that checks whether a file name contains the specified substring.
    /// </summary>
    [Obsolete]
    class SubstringFilePathMatcher
    {
        private string _substring;

        /// <summary>
        /// Initializes an instance of SubstringFilePathMatcher class by specifying the substring.
        /// </summary>
        /// <param name="substring">The substring that matched file name should contain.</param>
        public SubstringFilePathMatcher(string substring)
        {
            _substring = substring;
        }

        /// <summary>
        /// Determines whether the file name contains the specified substring.
        /// </summary>
        /// <param name="path">The path of the file.</param>
        /// <returns>A value indicating whether the file name contains the substring.</returns>
        public bool Match(string path)
        {
            return (Path.GetFileName(path)).Contains(_substring);
        }
    }
}
